***************************************************************
****Replication file for Ryan E. Carlin & Timothy Hellwig CPS
***************************************************************
*Table 1
use lb0203.dta

gen cntyyear = idenpa
recode cntyyear 1=102 2=202 3=302 4=402 5=502 6=602 7=702 8=802 9=902 10=1002 11=1102 12=1202 13=1302 14=1402 15=1502 17=1602 18=1702 if numinves==2002
recode cntyyear 1=103 2=203 3=303 4=403 5=503 6=603 7=703 8=803 9=903 10=1003 11=1103 12=1203 13=1303 14=1403 15=1503 16=1603 17=1703 if numinves==2003
gen country = cntyyear
recode country 102/103=1 202/203=2 302/303=3 402/403=4 502/503=5 602/603=6 702/703=7 802/803=8 902/903=9 1002/1003=10 1102/1103=11 1202/1203=12 1302/1303=13 1402/1403=14 1502/1503=15 1602/1603=16 1702/1703=17
drop riteideo
gen riteideo = riteideo2002+ riteideo2003
gen leftpres = cntyyear
recode leftpres 602=1 702=1 1002=1 1702=1 303=1 603=1 703=1 1703=1 *=0
gen govideo = 0
recode govideo *=1 if leftideo==1 & leftpres==1
recode govideo *=1 if riteideo==1 & leftpres==0
/*natural log of gdp in millions of usd*/
gen lngdp = cntyyear
recode lngdp 102=12.5 103=12.5 202=9 203=9 302=13.1 303=13.1 402=11.3 403=11.3 502=9.7 503=9.7 602=11.1 603=11.1 702=10 703=10 802=9.5 803=9.5 902=10 903=10 1002=8.8 1003=8.8 1102=13.3 1103=13.3 1202=8.3 1203=8.3 1302=9.4 1303=9.4 1402=8.8 1403=8.8 1502=10.9 1503=10.9 1602=9.8 1603=9.8 1702=11.7 1703=11.7
/*dfa4*/
gen dfa4 = cntyyear
recode dfa4 102=1.107 103=1.1974 202=5.117 203=5.333 302=.608 303=.847 402=.464 403=.534 502=-.399 503=-.325 602=4.380 603=4.555 702=.338 703=.457 802=1.646 803=1.812 902=1.283 903=1.513 1002=1.403 1003=1.594 1102=0.530 1103=0.622 1202=0.841 1203=1.043 1302=. 1303=. 1402=1.063 1403=1.294 1502=1.876 1503=2.019 1602=0.953 1603=.475 1702=.368 1703=1.051
/*dfa2*/
gen dfa2 = cntyyear
recode dfa2 102=.837 103=.759 202=.779 203=.797 302=2.308 303=2.308 402=1.873 403=1.841 502=1.165 503=1.188 602=-.729 603=-.726 702=-.454 703=-.442 802=-.695 803=-.699 902=-1.396 903=-1.310 1002=0.256 1003=0.362 1102=-.192 1103=-.182 1202=-.670 1203=-.694 1302=. 1303=. 1402=-.544 1403=-.578 1502=.899 1503=.853 1602=0.140 1603=-.483 1702=-0.490 1703=.115
/*cbi data for 2002 from Garriga 2016 International Interactions*/
gen cbi_garriga = idenpa
recode cbi_garriga 1=.823 2=.785 3=.166 4=.733 5=.735 6=.733 7=.827 8=.667 9=.684 10=.694 11=.671 12=.685 13=.297 14=.618 15=.811 16=.604 17=.635 18=.707 *=.
/*TABLE 1*/
gen rml2 = 1
recode rml2 *=2 if rgovpol==1 & rentrp==0
recode rml2 *=3 if rentrp==1 & rgovpol==0
gsem (i.rml2 <-dfa4 dfa2 lngdp govideo educ ses female age2640 age4160 age61plus yr2002 cbi_g M1[cntyyear]@1), mlogit
/*TABLE A5*/
gen rwig = rimf + rwto + rglobal
recode rwig 1/max=1
gen rwigstrict = rwig
recode rwigstrict *=0 if rgovpol==1 | rentrp==1 | rindiv==1 | rbanks==1 | rlackdom==1
xtmelogit rwigstr dfa4 dfa2 lngdp cbi_g govideo educ ses female age2640 age4160 age61plus yr2002 || cntyyear:, mle var

